package com.yonyou.brigade.order_center.service.impl;

import com.yonyou.brigade.order_center.model.BriTrainOrder;
import com.yonyou.brigade.order_center.model.BriTrainPassenger;
import com.yonyou.brigade.order_center.model.api.BriTrainOrderInfoAPIDTO;
import com.yonyou.brigade.order_center.service.IBriTrainOrderInfoAPIService;
import com.yonyou.brigade.order_center.service.IBriTrainOrderService;
import com.yonyou.brigade.order_center.service.IBriTrainPassengerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/8/31.
 */
@Service
public class BriTrainOrderInfoAPIServiceImpl implements IBriTrainOrderInfoAPIService{

    @Autowired
    @Qualifier("briTrainOrderServiceImpl")
    private IBriTrainOrderService briTrainOrderService;

    @Autowired
    @Qualifier("briTrainPassengerServiceImpl")
    private IBriTrainPassengerService briTrainPassengerService;

    @Override
    public List<BriTrainOrderInfoAPIDTO>   getBriTrainOrderInfoAPIDTOS(Map params) {
        List<BriTrainOrderInfoAPIDTO> briTrainOrderInfoAPIDTOs = new ArrayList<>();
        List<BriTrainOrder> briTrainOrders = briTrainOrderService.getBriTrainOrder(params);
        for (BriTrainOrder briTrainOrder : briTrainOrders){
            BriTrainOrderInfoAPIDTO briTrainOrderInfoAPIDTO = new BriTrainOrderInfoAPIDTO();
            briTrainOrderInfoAPIDTO.setBriTrainOrder(briTrainOrder);
            List<BriTrainPassenger> briTrainPassengers = briTrainPassengerService.getBriTrainPassenger(briTrainOrder.getOrderNo());
            briTrainOrderInfoAPIDTO.setBriTrainPassengers(briTrainPassengers);
            briTrainOrderInfoAPIDTOs.add(briTrainOrderInfoAPIDTO);
        }
        return briTrainOrderInfoAPIDTOs;
    }
}